package Euclid;

public class ErrorVarType extends VarType {
	
	String errorMessage;
	
	public ErrorVarType(String errmsg) {
		errorMessage = errmsg;
	}

	@Override
	public VarType add(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $+$ unsupported on type " + getClass());
	}

	@Override
	public String closeFormula() {
		return "\\text{" + errorMessage + "}";
	}

	@Override
	public VarType div(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $\\div$ unsupported on type " + getClass());
	}

	@Override
	public VarType mod(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation \\textbf{mod} unsupported on type " + getClass());
	}

	@Override
	public VarType mult(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $\\times$ unsupported on type " + getClass());
	}

	@Override
	public VarType negate() {
		return new ErrorVarType("Operation $-$ unsupported on type " + getClass());
	}

	@Override
	public VarType not() {
		return new ErrorVarType("Operation $\\sim$ unsupported on type " + getClass());
	}

	@Override
	public VarType pow(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $x^y$ unsupported on type " + getClass());
	}

	@Override
	public VarType subtract(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $-$ unsupported on type " + getClass());
	}

	public String toString() {
		return errorMessage;
	}
}
